package com.code.controller;

import com.code.domain.Items;
import com.code.model.Result;
import com.code.service.ItemsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Api(tags = "商品管理的接口")
public class ItemsController {

    @Autowired
    private ItemsService itemsService;

    /**
     * 这个接口需要公用
     * 查询热门商品 卖的比较多
     * 查询推荐商品 是否被推荐
     * city 城市
     * type 区分
     * @param city
     * @param type
     * @return
     */
    @GetMapping("hotProductOrRecommendation")
    @ApiOperation("查询推荐商品或者热门商品")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "city",value = "城市",dataType = "String",paramType = "query"),
            @ApiImplicitParam(name = "type",value = "类型",dataType = "Integer",paramType = "query")
    })
    public Result<List<Items>> getHotProductOrRecommendation(String city,Integer type){
        List<Items> itemsList = itemsService.findHotProductOrRecommendation(city,type);
        return Result.success("ok",itemsList);
    }
}
